package top.bug.blog.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import top.bug.blog.interceptor.LoginInterceptor;
import top.bug.blog.interceptor.UserInfoInterceptor;

import javax.annotation.Resource;

/**
 * @author <a href="https://github.com/jiusi66">九思.</a>
 * @email 10837907@qq.com
 * @from <a href="https://www.52bug.top">递归茶馆-www.52bug.top</a>
 * @description MVC 配置类
 */
@Configuration
public class MVCConfig implements WebMvcConfigurer {
    @Resource
    private UserInfoInterceptor userInfoInterceptor;
    @Resource
    private LoginInterceptor loginInterceptor;

    /**
     * 添加拦截器
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(userInfoInterceptor).order(0);
        registry.addInterceptor(loginInterceptor).order(1);
    }
}

